import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
// 引入vant
import Vant from 'vant'
import './assets/vant.css'
// 引入resetcss 和自定义全局样式
import './style/reset.less'
import './style/commit.less'
// 导入自定义组件
import UI from './components/index.js'
// 导入vant的指令
import './utils/vant'
import { global } from '@/utils'
Vue.prototype.$global = global
Vue.use(UI)
Vue.use(Vant)
Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App),
  // 移动端适配
  methods: {
    setRem (doc, win) {
      var docEl = doc.documentElement
      var resizeEvt =
                'orientationchange' in window ? 'orientationchange' : 'resize'
      var recalc = function () {
        var clientWidth = docEl.clientWidth
        if (!clientWidth) return
        if (clientWidth >= 375) {
          docEl.style.fontSize = 100 * (clientWidth / 375) + 'px'
        } else {
          docEl.style.fontSize = 100 * (clientWidth / 375) + 'px'
        }
      }

      if (!doc.addEventListener) return
      win.addEventListener(resizeEvt, recalc, false)
      doc.addEventListener('DOMContentLoaded', recalc, false)
    }
  },
  mounted () {
    // 设置rem大小
    this.setRem(document, window)
  }
}).$mount('#app')
